const { ccclass, property } = cc._decorator;
@ccclass
export default class SetActive extends cc.Component {
    @property()
    active: boolean = false;
    @property(cc.Node)
    nodeGo: cc.Node = null;

    start() {
        this.onClickEvent(this.node.getComponent(cc.Button), 'SetActive', 'setActiveEvent');
    }

    onClickEvent(btn: cc.Button, component: string, handler: string) {
        btn.clickEvents = [];
        var clickEventHandler = new cc.Component.EventHandler();
        clickEventHandler.target = btn.node;
        clickEventHandler.component = component;
        clickEventHandler.handler = handler;
        clickEventHandler.customEventData = '';
        btn.clickEvents.push(clickEventHandler);
    }
    setActiveEvent(): void {
        this.nodeGo.active = this.active;
    }
}
